
<script type="text/javascript">
$(document).ready(function() {
	$('.status').click(function(){
		var id = $(this).children("span").attr('value');
		var tmp = $("<img>");
		tmp.attr("src","/images/admin/loader.gif");	
		$(this).after(tmp);
		$.ajax({
			url:"/admin/parameter/changestatus/name/restaurant/id/"+id,
			cache:false,
			type:"POST",
			dataType:"text",
			success:function(data)
			{
				if(data == 1 )
					$("#status_"+id).attr('class','off');
				else
					$("#status_"+id).attr('class','on');
				tmp.remove();
			},
			error:function(data)
			{
				
			}
		});
	});
});
function search()
{
	var baseURL ="/admin/countryguide/restaurant";
	if ($('#namerestaurant').val())
	{
		baseURL += '/name/'+$('#namerestaurant').val();
	}
	baseURL += '/countryId/'+$('#countryId').val();
	baseURL += '/regionId/'+$('#regionId').val();
	window.location=baseURL;
}
</script>
<a class="button" style="float: right!important;margin :10px " href="<?php echo $this->url(array('controller'=>'countryguide','action'=>'addrestaurant')); ?>">Add New restaurant</a><br/>
<table>
	<tr><td class="button_search" style="margin-left: 30px;margin-bottom: 20px" onclick="search()" > Search </td> 
	<td class="box_search"  >Name : 
		<input name="namerestaurant" value="<?php echo $this->name; ?>" id="namerestaurant" type='text'  />
	</td> 
	<td class="box_search"  >Country : 
		<select onchange="search()" name="countryId" id="countryId" >
			<option value="0" > All Country </option>
			<?php foreach ($this->country as $country): ?>
				<option value="<?php echo $this->escape($country->id); ?>" <?php if ($this->escape($country->id)==$this->countryId) echo "selected='selected'"; ?>  ><?php echo $this->escape($country->name_en); ?></option>
			<?php endforeach; ?>
		</select>
	</td> 
	<td class="box_last_search"  >Region : 
		<select onchange="search()" name="regionId" id="regionId" >
			<option value="0" > All Region </option>
			<?php foreach ($this->region as $region): ?>
				<option value="<?php echo $this->escape($region->id); ?>" <?php if ($this->escape($region->id)==$this->regionId) echo "selected='selected'"; ?>  ><?php echo $this->escape($region->name_en); ?></option>
			<?php endforeach; ?>
		</select>
	</td>
	
	</tr>
</table>
<table class="table" >
<thead>
	<tr>
		<td>ID</td>
		<td>Name restaurant</td>
		<td>Place</td>
		<td>Spot</td>
		<td> Status </td>
		<td></td>
	</tr></thead>
	<tbody>
	<?php foreach ($this->restaurant as $restaurant): ?>
	<tr>
		<td  ><?php echo $this->escape($restaurant->id); ?></td>
		<td  ><?php echo $this->escape($restaurant->title_en); ?></td>
		<td  >Country : <?php echo $this->escape($restaurant->country); ?> <br/>
			  Region : <?php echo $this->escape($restaurant->region); ?> <br/>
			  City : <?php echo $this->escape($restaurant->city); ?> <br/>
		</td>
		<td  ><?php echo $this->escape($restaurant->spot); ?></td>
		<td style="width: 150px;"  ><div style="float:left;"> <div class="status" style="float:left;" > <span class="<?php if ($this->escape($restaurant['status']) == 1) echo "on";else echo "off";?>" id="status_<?php echo $this->escape($restaurant['id']); ?>" value="<?php echo $this->escape($restaurant['id']); ?>" >Status </span></div></div></td>
		<td width="105px" >
			<a class="help" href="<?php echo $this->url(array('controller'=>'countryguide',
				'action'=>'editrestaurant', 'id'=>$restaurant->id)); ?>">
				<span class="icon-button edit" > Edit </span>
				<span class="bullet" style="width: 24px;" >Edit</span>
				<span class="icon-button ui-icon-triangle-1-s queue" ></span>
				</a>
			<a class="help" href="<?php echo $this->url(array('controller'=>'countryguide',
				'action'=>'deleterestaurant', 'id'=>$restaurant->id)); ?>">
				<span class="icon-button delete" > Delete </span>
				<span class="bullet" style="width: 35px;" >Delete</span>
				<span class="icon-button ui-icon-triangle-1-s queue" ></span>
				</a>
		</td>
	</tr>
	<?php endforeach; ?>
	</tbody>
</table>